<template>
	<el-dialog title="快递订单提醒" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="提醒类型" prop="type">
				 <el-radio-group v-model="form.type">
				    <el-radio :label="1">公众号消息</el-radio>
				    <el-radio :label="2">短信提醒</el-radio>
				    <el-radio :label="3">语音提醒</el-radio>
				  </el-radio-group>
			
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false" >取 消</el-button>
			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">发 送</el-button>
		</template>
	</el-dialog>
</template>

<script>
	export default {
		emits: ['success', 'closed'],
		data() {
			return {
				visible: false,
				isSaveing: false,
				//表单数据
				form: {
					id:"",
					type: 1
				},
			}
		},
		mounted() {

		},
		methods: {
			//显示
			open(){
				this.visible = true;
				return this
			},
			//表单提交方法
			submit(){
				this.$refs.dialogForm.validate(async (valid) => {
					if (valid) {
						this.isSaveing = true;
						let form = JSON.parse(JSON.stringify(this.form))
						let res = await this.$API.order.express.nofity.post(this.form);
						delete form.type
						this.isSaveing = false;
						if(res.code == 200){
							this.$emit('success', form, this.mode || 'edit')
							this.visible = false;
							this.$message.success("操作成功")
						}else{
							this.$alert(res.msg, "提示", {type: 'error'})
						}
					}
				})
			},
			//表单注入数据
			setData(data){
				this.form.id = data.id
				// this.form.amount = data.amount
				// this.form.status = data.status
				// this.form.remark = data.remark

				//可以和上面一样单个注入，也可以像下面一样直接合并进去
				//Object.assign(this.form, data)
			}
		}
	}
</script>

<style>
</style>
